package net.gylka.newsreader;

import java.util.ArrayList;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ListView;

public class ArticleListFragment extends Fragment {

	private NewsSite mNewsSite;
	private ListView mArticleListView;
	private ArticleListAdapter mArticleListAdapter;
	private ArrayList<Article> mArticleList;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		Bundle bundle = this.getActivity().getIntent().getExtras();
		this.mNewsSite = new NewsSite();
		mNewsSite.mId = bundle.getInt(BaseNewsReaderActivity.PACKAGE_NAME + ".SiteName");

		// TODO: Provide handling different source sites and load article list
		mArticleList = new ArrayList<Article>();
		mArticleList.add(new Article() {{
			setTitle("sdfsdf");
		}});
		
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View fragmentView = inflater.inflate(R.layout.fragment_article_list, container, false);
		mArticleListAdapter = new ArticleListAdapter(this.getActivity(), R.layout.list_article_item, mArticleList);
		mArticleListView = (ListView) fragmentView.findViewById(R.id.listArticleList);
		mArticleListView.setAdapter(mArticleListAdapter);
		return fragmentView;
	}

}
